//
//  AccountViewController.m
//  跨界收
//
//  Created by MT on 2018/10/27.
//  Copyright © 2018年 gztx. All rights reserved.
//

#import "AccountViewController.h"
#import "AccountHeaderView.h"
#import "AccountFooterView.h"
#import "XBZPYOptionManager.h"
#import "IMSScannerViewController.h"
#import "ShouKuanTowViewController.h"
#import "ShouKuanViewController.h"
#import "CodeBarViewController.h"
#import "SignViewController.h"

@interface AccountViewController ()
@property (weak, nonatomic) IBOutlet UITableView *mainTableView;
@property (nonatomic,strong) AccountHeaderView *header;
@property (nonatomic,strong) AccountFooterView *footer;
@property (nonatomic, strong) PYEchartsView *echartsView;
@property (nonatomic, strong) PYOption *option;
@end

@implementation AccountViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setupUI];
    
    [self setEchartsViewDate];
}

- (void)setupUI{
    self.mainTableView.tableHeaderView = [self tableHeaderView];
    self.mainTableView.tableFooterView = [self tableFooterView];
    
    [_header.scanBtn addTarget:self action:@selector(scanAction:) forControlEvents:UIControlEventTouchUpInside];
    [_header.QRCodeBtn addTarget:self action:@selector(QRCodeAction:) forControlEvents:UIControlEventTouchUpInside];
    [_header.checkstandBtn addTarget:self action:@selector(checkstandAction:) forControlEvents:UIControlEventTouchUpInside];
    [_header.statisticsBtn addTarget:self action:@selector(statisticsAction:) forControlEvents:UIControlEventTouchUpInside];
    [_header.signBtn addTarget:self action:@selector(signAction:) forControlEvents:UIControlEventTouchUpInside];
    [_header.detailBtn addTarget:self action:@selector(detailAction:) forControlEvents:UIControlEventTouchUpInside];
    
    self.echartsView = [[PYEchartsView alloc] init];
    [self.footer.echartsBgView addSubview:self.echartsView];
    [self.echartsView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(self.footer.echartsBgView);
    }];
}

- (UIView *)tableHeaderView
{
    UIView *tableHeaderView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 220)];
    tableHeaderView.backgroundColor = PORJECT_COLOR;
    _header =  [[[NSBundle mainBundle] loadNibNamed:@"AccountHeaderView" owner:self options:nil] lastObject];
    [tableHeaderView addSubview:_header];
    [_header mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(tableHeaderView);
    }];
    return tableHeaderView;
}

- (UIView *)tableFooterView
{
    UIView *tableFooterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 307)];
    tableFooterView.backgroundColor = BG_GARY_COLOR;
    _footer =  [[[NSBundle mainBundle] loadNibNamed:@"AccountFooterView" owner:self options:nil] lastObject];
    _footer.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageWithColor:[UIColor whiteColor]]];
    [tableFooterView addSubview:_footer];
    [_footer mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.height.mas_equalTo(287);
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
    }];
    return tableFooterView;
}

- (void)setEchartsViewDate {
    self.option = [XBZPYOptionManager configOptionWithStack:@[@"common"]];
//    self.option.color = @[@"#FF0000"];
    
    self.option.xAxis.firstObject.data = @[@"05-02", @"05-03", @"05-04", @"05-05", @"05-06"].mutableCopy;
    self.option.series.firstObject.dataEqual(@[@"0.0", @"0.2", @"0.3", @"0.4", @"0.5"]);
    
    [self.echartsView setOption:self.option];
    [self.echartsView loadEcharts];
}


#pragma mark - event -
//扫一扫
- (void)scanAction:(UIButton *)sender{
    IMSScannerViewController *scannerVC = [[IMSScannerViewController alloc] init];
    scannerVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:scannerVC animated:YES];
}
//收款码
- (void)QRCodeAction:(UIButton *)sender{
    NSArray *titleArr = @[@"去收款",@"收款码"];
    NSArray *vcArr = @[[ShouKuanViewController class],[CodeBarViewController class],];
    ShouKuanTowViewController *recordVC = [[ShouKuanTowViewController alloc] initWithViewControllerClasses:vcArr andTheirTitles:titleArr];
    recordVC.menuItemWidth = SCREEN_WIDTH/2.0;
    recordVC.menuViewStyle = WMMenuViewStyleLine;
    recordVC.titleColorNormal = [UIColor whiteColor];
    recordVC.titleColorSelected = [UIColor cz_colorWithHex:0xF6F6F6];
    recordVC.progressWidth = 50.0;
    recordVC.progressHeight = 2.0;
    recordVC.progressColor = [UIColor whiteColor];
    recordVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:recordVC animated:YES];
}
//收银台
- (void)checkstandAction:(UIButton *)sender{
    
}
//财务统计
- (void)statisticsAction:(UIButton *)sender{
    
}
//签约管理
- (void)signAction:(UIButton *)sender{
    SignViewController *signVC = [[SignViewController alloc] initWithNibName:@"SignViewController" bundle:nil];
    signVC.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:signVC animated:YES];
}
//交易明细
- (void)detailAction:(UIButton *)sender{
    
}

#pragma mark - tableview -
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 0;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}


@end
